package simpleGeom;

public class BucketMapper {
float min=Float.POSITIVE_INFINITY;
float max=Float.NEGATIVE_INFINITY;
float delta=0;
int[]buckets;
int sumEntries=0;

public void crop(float min,float max){
	min=min;// +first 5 percent
	max=max;// -last 5 percent		
}

public BucketMapper(int nBuckets){
	 min=Float.POSITIVE_INFINITY;
	 max=Float.NEGATIVE_INFINITY;
	 buckets=new int[nBuckets];
}
public BucketMapper(float min,float max){
	this.min=min;
	this.max=max;
}
float getPercentage(float v){
	return (v-min)/(max-min);
}
float getLogarithmic(float v){
	return 0;
}
public int getBucket(float v){
	float d=v-min;
	int i=Math.round(d*(max-min)/buckets.length);
	return i;
}
public void addValue(float v){
	if (v<min)min=v;
	if (v>max)max=v;
	
}
public int[] getBuckets() {
	return buckets;
}
public void setBuckets(int[] buckets) {
	this.buckets = buckets;
}
public void addValueToBucket(float v){
	int i=getBucket(v);
	buckets[i]++;
	sumEntries++;
}
}
